package com.itjavas.cslp2.controller;

import com.itjavas.cslp2.pojo.entity.Course;
import com.itjavas.cslp2.pojo.entity.User;
import com.itjavas.cslp2.service.CourseService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.AttributedString;
import java.util.List;

@RestController//表明是控制类
@RequestMapping("/course")//声明目录
@ResponseBody
public class CourseController {
    @Autowired
    public CourseService courseService;

    //创建课程
    @RequestMapping("/createCourse")
    public ResponseEntity<Boolean> createCourse(@RequestBody Course course){
        return courseService.createCourse(course);
    }

    //查询课程列表
    @RequestMapping("/queryAllCourse")
    public  ResponseEntity<List<Course>> queryAllCourse(){
        return ResponseEntity.ok(courseService.findAllCourse());
    }

    //编辑课程
    @RequestMapping("/editCourse")
    public ResponseEntity<Boolean> editCourse(@RequestBody Course course){
        return courseService.editCourse(course);
    }

    //删除课程
    @RequestMapping("/deleteCourse")
    public ResponseEntity<Boolean> deleteCourse(@RequestParam String courseId){
        System.out.println(courseId);
        return courseService.deleteCourse(courseId);
    }
    //审核用户上传的资料
    @RequestMapping("/examMaterial")
    public ResponseEntity<Boolean> examMaterial(@RequestBody Course course){
        return courseService.examMaterial(course);
    }
}
